import React from 'react'
import type { FC } from 'react'
import MyLine from './MyLine'
import MyBar from './MyBar'

interface IProps {
  type: 'line' | 'bar'
  xdata: string[]
  // series: Array<Record<string, any> & { data: number[] | Record<string, any>[] }>
  series: Array<
    Record<string, any> & { data: (number | Record<string, any>)[] }
  >
  [key: string]: any
}

// 容器 或 控制器
const MyChart: FC<IProps> = (props) => {
  // const seriesData = props.series.map((item) => {
  //   return {
  //     ...item,
  //     data: item.data as number[]
  //   }
  // })
  return (
    <>
      {/* {props.type === 'line' ? <MyLine {...props} series={seriesData} /> : null} */}
      {props.type === 'line' ? <MyLine {...props} /> : null}
      {props.type === 'bar' ? <MyBar {...props} /> : null}
    </>
  )
}

export default MyChart
